package cn.snowheart.command.command;

import cn.snowheart.command.inter.CeilingFan;

/**
 * @author liuwanxiang
 * @version 2019/07/04
 */
public abstract class CeilingFanCommand implements Command {

    CeilingFan ceilingFan;
    int prevSpeed;

    CeilingFanCommand(CeilingFan ceilingFan) {
        this.ceilingFan = ceilingFan;
    }

    @Override
    public void undo() {
        switch (this.prevSpeed) {
            case CeilingFan.HIGH:
                ceilingFan.high();
                break;
            case CeilingFan.MEDIUM:
                ceilingFan.medium();
                break;
            case CeilingFan.LOW:
                ceilingFan.low();
                break;
            case CeilingFan.OFF:
                ceilingFan.off();
                break;
            default:
                System.out.println("parameter not right~");
                break;
        }
    }
}
